<?
include "server_config.php";
?>
<result>
<?
if (!isset($_GET['type'])) { ?>
	<error>이유를 선택해 주세요</error>
</result><?
	exit;
}

$user_idx = $_SESSION['user_idx'];
$sql = "
	SELECT COUNT(*) FROM ndd_comment_accuse WHERE comment_idx=$comment_idx && user_idx=$user_idx;
";
$result = mysql_query($sql,$connect);
$row = mysql_fetch_row($result);
if ($row[0] >= 1)
{
?>
	<error>한 댓글에는 한 번의 신고만 가능합니다.</error>
<?
} else {
	$type = $_GET['type'];
	$sql="
		INSERT INTO ndd_comment_accuse VALUES ($comment_idx, $user_idx, $type, '$comment');
	";
	mysql_query($sql,$connect);
	$sql="
		UPDATE ndd_comment SET accuse_count=accuse_count+1 WHERE comment_idx=$comment_idx;
	";
	mysql_query($sql,$connect);
	$sql="
		SELECT accuse_count FROM ndd_comment WHERE comment_idx=$comment_idx;
	";
	$result = mysql_query($sql,$connect);
	$row = mysql_fetch_row($result);
	$count = $row[0];
?>
	<count><? echo $count; ?></count>
<?
}
?>
</result>
